//
//  EcodeTask.m
//  RunLoopDemo
//
//  Created by zhangjikuan on 2020/9/23.
//  Copyright © 2020 hsgd. All rights reserved.
//

#import "EcodeTask.h"
#import "Book.h"
@implementation EcodeTask
- (void)execute {

    // 存到本地
    Book *book = [[Book alloc] init];
    book.title = @"《平凡的世界》";
    book.autoher = @"路遥";
    book.isPublish = YES;
    
    NSString *filePath = NSTemporaryDirectory();
    filePath = [NSString stringWithFormat:@"%@\%@",filePath, @"book"];

    
    [NSKeyedArchiver archiveRootObject:book toFile:filePath];
    
    //从本地取出
    Book *theBook = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
    
    
    NSLog(@"book %@", theBook.title);
    
    Book *cpBook = [theBook copy];
    
    
    NSLog(@"book %@", cpBook.title);

    
    
}
@end
